<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QGraphicsItemAnimation Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QGraphicsItemAnimation Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QGraphicsItemAnimation class provides simple animation
support for <a href="qgraphicsitem.html">QGraphicsItem</a>.
<a href="#details">More...</a></p>

<p>Inherits <a href="qobject.html">QObject</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qgraphicsitemanimation.html#QGraphicsItemAnimation">__init__</a></b> (<i>self</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qgraphicsitemanimation.html#afterAnimationStep">afterAnimationStep</a></b> (<i>self</i>, float&#160;<i>step</i>)</li><li><div class="fn" /><b><a href="qgraphicsitemanimation.html#beforeAnimationStep">beforeAnimationStep</a></b> (<i>self</i>, float&#160;<i>step</i>)</li><li><div class="fn" /><b><a href="qgraphicsitemanimation.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qgraphicsitemanimation.html#horizontalScaleAt">horizontalScaleAt</a></b> (<i>self</i>, float&#160;<i>step</i>)</li><li><div class="fn" />float <b><a href="qgraphicsitemanimation.html#horizontalShearAt">horizontalShearAt</a></b> (<i>self</i>, float&#160;<i>step</i>)</li><li><div class="fn" />QGraphicsItem <b><a href="qgraphicsitemanimation.html#item">item</a></b> (<i>self</i>)</li><li><div class="fn" />QMatrix <b><a href="qgraphicsitemanimation.html#matrixAt">matrixAt</a></b> (<i>self</i>, float&#160;<i>step</i>)</li><li><div class="fn" />QPointF <b><a href="qgraphicsitemanimation.html#posAt">posAt</a></b> (<i>self</i>, float&#160;<i>step</i>)</li><li><div class="fn" />list-of-tuple-of-float-QPointF <b><a href="qgraphicsitemanimation.html#posList">posList</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsitemanimation.html#reset">reset</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qgraphicsitemanimation.html#rotationAt">rotationAt</a></b> (<i>self</i>, float&#160;<i>step</i>)</li><li><div class="fn" />list-of-tuple-of-float-float <b><a href="qgraphicsitemanimation.html#rotationList">rotationList</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-tuple-of-float-QPointF <b><a href="qgraphicsitemanimation.html#scaleList">scaleList</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsitemanimation.html#setItem">setItem</a></b> (<i>self</i>, QGraphicsItem&#160;<i>item</i>)</li><li><div class="fn" /><b><a href="qgraphicsitemanimation.html#setPosAt">setPosAt</a></b> (<i>self</i>, float&#160;<i>step</i>, QPointF&#160;<i>pos</i>)</li><li><div class="fn" /><b><a href="qgraphicsitemanimation.html#setRotationAt">setRotationAt</a></b> (<i>self</i>, float&#160;<i>step</i>, float&#160;<i>angle</i>)</li><li><div class="fn" /><b><a href="qgraphicsitemanimation.html#setScaleAt">setScaleAt</a></b> (<i>self</i>, float&#160;<i>step</i>, float&#160;<i>sx</i>, float&#160;<i>sy</i>)</li><li><div class="fn" /><b><a href="qgraphicsitemanimation.html#setShearAt">setShearAt</a></b> (<i>self</i>, float&#160;<i>step</i>, float&#160;<i>sh</i>, float&#160;<i>sv</i>)</li><li><div class="fn" /><b><a href="qgraphicsitemanimation.html#setStep">setStep</a></b> (<i>self</i>, float&#160;<i>x</i>)</li><li><div class="fn" /><b><a href="qgraphicsitemanimation.html#setTimeLine">setTimeLine</a></b> (<i>self</i>, QTimeLine&#160;<i>timeLine</i>)</li><li><div class="fn" /><b><a href="qgraphicsitemanimation.html#setTranslationAt">setTranslationAt</a></b> (<i>self</i>, float&#160;<i>step</i>, float&#160;<i>dx</i>, float&#160;<i>dy</i>)</li><li><div class="fn" />list-of-tuple-of-float-QPointF <b><a href="qgraphicsitemanimation.html#shearList">shearList</a></b> (<i>self</i>)</li><li><div class="fn" />QTimeLine <b><a href="qgraphicsitemanimation.html#timeLine">timeLine</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-tuple-of-float-QPointF <b><a href="qgraphicsitemanimation.html#translationList">translationList</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qgraphicsitemanimation.html#verticalScaleAt">verticalScaleAt</a></b> (<i>self</i>, float&#160;<i>step</i>)</li><li><div class="fn" />float <b><a href="qgraphicsitemanimation.html#verticalShearAt">verticalShearAt</a></b> (<i>self</i>, float&#160;<i>step</i>)</li><li><div class="fn" />float <b><a href="qgraphicsitemanimation.html#xTranslationAt">xTranslationAt</a></b> (<i>self</i>, float&#160;<i>step</i>)</li><li><div class="fn" />float <b><a href="qgraphicsitemanimation.html#yTranslationAt">yTranslationAt</a></b> (<i>self</i>, float&#160;<i>step</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QGraphicsItemAnimation class provides simple animation
support for <a href="qgraphicsitem.html">QGraphicsItem</a>.</p>
<p>The QGraphicsItemAnimation class animates a <a href="qgraphicsitem.html">QGraphicsItem</a>. You can schedule changes to
the item's transformation matrix at specified steps. The
QGraphicsItemAnimation class has a current step value. When this
value changes the transformations scheduled at that step are
performed. The current step of the animation is set with the
<tt>setStep()</tt> function.</p>
<p>QGraphicsItemAnimation will do a simple linear interpolation
between the nearest adjacent scheduled changes to calculate the
matrix. For instance, if you set the position of an item at values
0.0 and 1.0, the animation will show the item moving in a straight
line between these positions. The same is true for scaling and
rotation.</p>
<p>It is usual to use the class with a <a href="qtimeline.html">QTimeLine</a>. The timeline's <a href="qtimeline.html#valueChanged">valueChanged()</a> signal is then
connected to the <tt>setStep()</tt> slot. For example, you can set
up an item for rotation by calling <tt>setRotationAt()</tt> for
different step values. The animations timeline is set with the
<a href="qgraphicsitemanimation.html#setTimeLine">setTimeLine</a>()
function.</p>
<p>An example animation with a timeline follows:</p>
<pre class="cpp">
     <span class="type"><a href="qgraphicsitem.html">QGraphicsItem</a></span> <span class="operator">*</span>ball <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgraphicsellipseitem.html">QGraphicsEllipseItem</a></span>(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">20</span><span class="operator">,</span> <span class="number">20</span>);

     <span class="type"><a href="qtimeline.html">QTimeLine</a></span> <span class="operator">*</span>timer <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qtimeline.html">QTimeLine</a></span>(<span class="number">5000</span>);
     timer<span class="operator">-</span><span class="operator">&gt;</span>setFrameRange(<span class="number">0</span><span class="operator">,</span> <span class="number">100</span>);

     <span class="type">QGraphicsItemAnimation</span> <span class="operator">*</span>animation <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QGraphicsItemAnimation</span>;
     animation<span class="operator">-</span><span class="operator">&gt;</span>setItem(ball);
     animation<span class="operator">-</span><span class="operator">&gt;</span>setTimeLine(timer);

     <span class="keyword">for</span> (<span class="type">int</span> i <span class="operator">=</span> <span class="number">0</span>; i <span class="operator">&lt;</span> <span class="number">200</span>; <span class="operator">+</span><span class="operator">+</span>i)
         animation<span class="operator">-</span><span class="operator">&gt;</span>setPosAt(i <span class="operator">/</span> <span class="number">200.0</span><span class="operator">,</span> <span class="type"><a href="qpointf.html">QPointF</a></span>(i<span class="operator">,</span> i));

     <span class="type"><a href="qgraphicsscene.html">QGraphicsScene</a></span> <span class="operator">*</span>scene <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgraphicsscene.html">QGraphicsScene</a></span>();
     scene<span class="operator">-</span><span class="operator">&gt;</span>setSceneRect(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">250</span><span class="operator">,</span> <span class="number">250</span>);
     scene<span class="operator">-</span><span class="operator">&gt;</span>addItem(ball);

     <span class="type"><a href="qgraphicsview.html">QGraphicsView</a></span> <span class="operator">*</span>view <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgraphicsview.html">QGraphicsView</a></span>(scene);
     view<span class="operator">-</span><span class="operator">&gt;</span>show();

     timer<span class="operator">-</span><span class="operator">&gt;</span>start();
</pre>
<p>Note that steps lie between 0.0 and 1.0. It may be necessary to
use <a href="qtimeline.html#updateInterval-prop">setUpdateInterval()</a>. The
default update interval is 40 ms. A scheduled transformation cannot
be removed when set, so scheduling several transformations of the
same kind (e.g., rotations) at the same step is not
recommended.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QGraphicsItemAnimation" />QGraphicsItemAnimation.__init__ (<i>self</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs an animation object with the given <i>parent</i>.</p>


<h3 class="fn"><a name="afterAnimationStep" />QGraphicsItemAnimation.afterAnimationStep (<i>self</i>, float&#160;<i>step</i>)</h3><p>This method is meant to be overridden in subclasses that need to
execute additional code after a new step has taken place. The
animation <i>step</i> is provided for use in cases where the action
depends on its value.</p>


<h3 class="fn"><a name="beforeAnimationStep" />QGraphicsItemAnimation.beforeAnimationStep (<i>self</i>, float&#160;<i>step</i>)</h3><p>This method is meant to be overridden by subclassed that needs
to execute additional code before a new step takes place. The
animation <i>step</i> is provided for use in cases where the action
depends on its value.</p>


<h3 class="fn"><a name="clear" />QGraphicsItemAnimation.clear (<i>self</i>)</h3><p>Clears the scheduled transformations used for the animation, but
retains the item and timeline.</p>


<h3 class="fn"><a name="horizontalScaleAt" />float QGraphicsItemAnimation.horizontalScaleAt (<i>self</i>, float&#160;<i>step</i>)</h3><p>Returns the horizontal scale for the item at the specified
<i>step</i> value.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#setScaleAt">setScaleAt</a>().</p>


<h3 class="fn"><a name="horizontalShearAt" />float QGraphicsItemAnimation.horizontalShearAt (<i>self</i>, float&#160;<i>step</i>)</h3><p>Returns the horizontal shear for the item at the specified
<i>step</i> value.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#setShearAt">setShearAt</a>().</p>


<h3 class="fn"><a name="item" /><a href="qgraphicsitem.html">QGraphicsItem</a> QGraphicsItemAnimation.item (<i>self</i>)</h3><p>Returns the item on which the animation object operates.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#setItem">setItem</a>().</p>


<h3 class="fn"><a name="matrixAt" /><a href="qmatrix.html">QMatrix</a> QGraphicsItemAnimation.matrixAt (<i>self</i>, float&#160;<i>step</i>)</h3><p>Returns the matrix used to transform the item at the specified
<i>step</i> value.</p>


<h3 class="fn"><a name="posAt" /><a href="qpointf.html">QPointF</a> QGraphicsItemAnimation.posAt (<i>self</i>, float&#160;<i>step</i>)</h3><p>Returns the position of the item at the given <i>step</i>
value.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#setPosAt">setPosAt</a>().</p>


<h3 class="fn"><a name="posList" />list-of-tuple-of-float-QPointF QGraphicsItemAnimation.posList (<i>self</i>)</h3><p>Returns all explicitly inserted positions.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#posAt">posAt</a>() and <a href="qgraphicsitemanimation.html#setPosAt">setPosAt</a>().</p>


<h3 class="fn"><a name="reset" />QGraphicsItemAnimation.reset (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void reset()</tt>.</p><h3 class="fn"><a name="rotationAt" />float QGraphicsItemAnimation.rotationAt (<i>self</i>, float&#160;<i>step</i>)</h3><p>Returns the angle at which the item is rotated at the specified
<i>step</i> value.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#setRotationAt">setRotationAt</a>().</p>


<h3 class="fn"><a name="rotationList" />list-of-tuple-of-float-float QGraphicsItemAnimation.rotationList (<i>self</i>)</h3><p>Returns all explicitly inserted rotations.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#rotationAt">rotationAt</a>() and
<a href="qgraphicsitemanimation.html#setRotationAt">setRotationAt</a>().</p>


<h3 class="fn"><a name="scaleList" />list-of-tuple-of-float-QPointF QGraphicsItemAnimation.scaleList (<i>self</i>)</h3><p>Returns all explicitly inserted scales.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#verticalScaleAt">verticalScaleAt</a>(),
<a href="qgraphicsitemanimation.html#horizontalScaleAt">horizontalScaleAt</a>(),
and <a href="qgraphicsitemanimation.html#setScaleAt">setScaleAt</a>().</p>


<h3 class="fn"><a name="setItem" />QGraphicsItemAnimation.setItem (<i>self</i>, <a href="qgraphicsitem.html">QGraphicsItem</a>&#160;<i>item</i>)</h3><p>Sets the specified <i>item</i> to be used in the animation.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#item">item</a>().</p>


<h3 class="fn"><a name="setPosAt" />QGraphicsItemAnimation.setPosAt (<i>self</i>, float&#160;<i>step</i>, <a href="qpointf.html">QPointF</a>&#160;<i>pos</i>)</h3><p>Sets the position of the item at the given <i>step</i> value to
the <i>point</i> specified.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#posAt">posAt</a>().</p>


<h3 class="fn"><a name="setRotationAt" />QGraphicsItemAnimation.setRotationAt (<i>self</i>, float&#160;<i>step</i>, float&#160;<i>angle</i>)</h3><p>Sets the rotation of the item at the given <i>step</i> value to
the <i>angle</i> specified.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#rotationAt">rotationAt</a>().</p>


<h3 class="fn"><a name="setScaleAt" />QGraphicsItemAnimation.setScaleAt (<i>self</i>, float&#160;<i>step</i>, float&#160;<i>sx</i>, float&#160;<i>sy</i>)</h3><p>Sets the scale of the item at the given <i>step</i> value using
the horizontal and vertical scale factors specified by <i>sx</i>
and <i>sy</i>.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#verticalScaleAt">verticalScaleAt</a>()
and <a href="qgraphicsitemanimation.html#horizontalScaleAt">horizontalScaleAt</a>().</p>


<h3 class="fn"><a name="setShearAt" />QGraphicsItemAnimation.setShearAt (<i>self</i>, float&#160;<i>step</i>, float&#160;<i>sh</i>, float&#160;<i>sv</i>)</h3><p>Sets the shear of the item at the given <i>step</i> value using
the horizontal and vertical shear factors specified by <i>sh</i>
and <i>sv</i>.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#verticalShearAt">verticalShearAt</a>()
and <a href="qgraphicsitemanimation.html#horizontalShearAt">horizontalShearAt</a>().</p>


<h3 class="fn"><a name="setStep" />QGraphicsItemAnimation.setStep (<i>self</i>, float&#160;<i>x</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void setStep(qreal)</tt>.</p><p>Sets the current <i>step</i> value for the animation, causing
the transformations scheduled at this step to be performed.</p>


<h3 class="fn"><a name="setTimeLine" />QGraphicsItemAnimation.setTimeLine (<i>self</i>, <a href="qtimeline.html">QTimeLine</a>&#160;<i>timeLine</i>)</h3><p>Sets the timeline object used to control the rate of animation
to the <i>timeLine</i> specified.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#timeLine">timeLine</a>().</p>


<h3 class="fn"><a name="setTranslationAt" />QGraphicsItemAnimation.setTranslationAt (<i>self</i>, float&#160;<i>step</i>, float&#160;<i>dx</i>, float&#160;<i>dy</i>)</h3><p>Sets the translation of the item at the given <i>step</i> value
using the horizontal and vertical coordinates specified by
<i>dx</i> and <i>dy</i>.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#xTranslationAt">xTranslationAt</a>()
and <a href="qgraphicsitemanimation.html#yTranslationAt">yTranslationAt</a>().</p>


<h3 class="fn"><a name="shearList" />list-of-tuple-of-float-QPointF QGraphicsItemAnimation.shearList (<i>self</i>)</h3><p>Returns all explicitly inserted shears.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#verticalShearAt">verticalShearAt</a>(),
<a href="qgraphicsitemanimation.html#horizontalShearAt">horizontalShearAt</a>(),
and <a href="qgraphicsitemanimation.html#setShearAt">setShearAt</a>().</p>


<h3 class="fn"><a name="timeLine" /><a href="qtimeline.html">QTimeLine</a> QGraphicsItemAnimation.timeLine (<i>self</i>)</h3><p>Returns the timeline object used to control the rate at which
the animation occurs.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#setTimeLine">setTimeLine</a>().</p>


<h3 class="fn"><a name="translationList" />list-of-tuple-of-float-QPointF QGraphicsItemAnimation.translationList (<i>self</i>)</h3><p>Returns all explicitly inserted translations.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#xTranslationAt">xTranslationAt</a>(),
<a href="qgraphicsitemanimation.html#yTranslationAt">yTranslationAt</a>(),
and <a href="qgraphicsitemanimation.html#setTranslationAt">setTranslationAt</a>().</p>


<h3 class="fn"><a name="verticalScaleAt" />float QGraphicsItemAnimation.verticalScaleAt (<i>self</i>, float&#160;<i>step</i>)</h3><p>Returns the vertical scale for the item at the specified
<i>step</i> value.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#setScaleAt">setScaleAt</a>().</p>


<h3 class="fn"><a name="verticalShearAt" />float QGraphicsItemAnimation.verticalShearAt (<i>self</i>, float&#160;<i>step</i>)</h3><p>Returns the vertical shear for the item at the specified
<i>step</i> value.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#setShearAt">setShearAt</a>().</p>


<h3 class="fn"><a name="xTranslationAt" />float QGraphicsItemAnimation.xTranslationAt (<i>self</i>, float&#160;<i>step</i>)</h3><p>Returns the horizontal translation of the item at the specified
<i>step</i> value.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#setTranslationAt">setTranslationAt</a>().</p>


<h3 class="fn"><a name="yTranslationAt" />float QGraphicsItemAnimation.yTranslationAt (<i>self</i>, float&#160;<i>step</i>)</h3><p>Returns the vertical translation of the item at the specified
<i>step</i> value.</p>
<p><b>See also</b> <a href="qgraphicsitemanimation.html#setTranslationAt">setTranslationAt</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.9.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2011</td><td align="right" width="25%">Qt&#160;4.8.0</td></tr></table></div></address></body></html>